import Vue from 'vue'

import ElementUI from 'element-ui'//引入element-ui库

import 'element-ui/lib/theme-chalk/index.css'//引入库中的样式

import App from './App.vue' //主页面

import router from'./router/index.js' //路由

import vueEsign from 'vue-esign'//画板工具

import store from './store/index.js'

Vue.config.productionTip = false
Vue.use(ElementUI) //将element-ui配置到vue项目中,一般不会这样用的,还可以按需使用
Vue.use(vueEsign)//画板工具


router.beforeEach((to,from,next)=>{
  store.commit('getToken')//可能页面更新会丢失数据
  const token=store.state.token
  //if(!token&&to.name!=='login'){  //if(!token&&to.name!=='login'){
      // next({name:'login'})
 // }
  if(to.name==='regfrom'||to.name==='showcourse'||to.name==='showweekcourse'||to.name==='showcourse2'||to.name==='teacherlogin'||to.name==='teachershowno'||to.name==="regfrom2"){
       next()
  }
  else if(!token&&to.name!=='login'){  //if(!token&&to.name!=='login'){
    next({name:'login'})
  }
  else{
    next()
  }
})
new Vue({

  router,
  store,

  render: h => h(App),
  
}).$mount('#app')
